home *** CD-ROM | disk | FTP | other *** search
- /* keyio1.c - getkey() and keypress() functions */
- /* system dependant part of the keyboard input module */
- /* this version uses BIOS function calls */
- #include "stdio.h"
- #include "cminor.h"
- #include "asmtools.h"
- #include "dosfun.h"
- #include "keyio.h"
-
- /* constants for BIOS calls */
- #define KEYIO_CALL 0x16 /* software interrupt number */
- #define CHK_STAT 0x0100 /* function code for check input status */
- #define GET_CHR 0x0000 /* function code for getting a char */
-
- int keypress() /* check for keyboard input waiting */
- {
- int stat ;
- REGS sreg , dreg ;
-
- sreg.ax = CHK_STAT ; /* do BIOS call to check status */
- stat = swint(KEYIO_CALL,&sreg,&dreg) & ZF_FLAG ;
-
- if( stat == 0 )
- return( 1 ) ; /* input is waiting */
- else return( 0 ) ; /* no input waiting */
- }
-
-
- /* getkey - waits for and returns the next keystroke input */
- /* keystrokes that the ROM-BIOS describes with extended codes */
- /* are returned as integers > 255 */
-
- int getkey() /* get the next key input */
- {
- int c ;
- REGS sreg , dreg ;
-
- sreg.ax = GET_CHR ;
- swint(KEYIO_CALL,&sreg,&dreg) ;
- c = dreg.ax & 0xff ; /* get ASCII code */
- if( c == 0 ) /* is it a non-ASCII extended code */
- c = 0x100 + (dreg.ax >> 8) ; /* yes - use 256 + scan code */
- return( c ) ;
- }
-
-
-
-